// 客户接口
export interface Customer {
  id: number
  name: string
  address: string
  tax_num: string
  tax_bank: string
  tax_banksn: string
  tax_mobile: string
  tax_address: string
  contact_name?: string
  contact_mobile?: string
  belong_uid: number
  belong_did: number
  is_lock: number
  create_time: string
  update_time: string
  delete_time: number
  // 废弃相关字段
  discard_time?: string
  discard_reason?: string
  // 扩展字段
  belong_name?: string
  belong_department?: string
  // 添加缺失的属性
  creator?: {
    id?: number
    uid?: number
    name?: string
  }
  admin_id?: number

  grade?: string
  grade_name?: string
  grade_id?: number
  source?: string
  source_name?: string
  source_id?: number
  customer_status_name?: string

  customer_type?: number
  customer_type_name?: string
  customer_region?: string
  provinceid?: number
  cityid?: number
  distid?: number
  // 地区名称字段
  province_name?: string
  city_name?: string
  district_name?: string
  follow_time?: string
  next_time?: string
  contacter?: string
  mobile?: string
  email?: string
  contract_num?: number
  contract_amount?: number
  description?: string

  // 新增字段
  group_code?: string
  is_primary?: number
  controller_name?: string
  relation_desc?: string
  // 会员相关字段
  customer_status?: number
  customer_attribute?: number
  member_type?: number
  member_start_time?: string
  member_end_time?: string
}

// 客户联系人接口
export interface CustomerContact {
  id: number
  cid: number
  name: string
  mobile: string
  sex: number
  qq: string
  wechat: string
  email: string
  nickname?: string
  department?: string
  birthday?: string
  address?: string
  family?: string
  position?: string
  admin_id: number
  is_default: number
  create_time: string
  update_time: string
  delete_time?: number
  // 添加客户名称字段
  customer_name?: string
}

// 客户跟进记录接口
export interface CustomerTrace {
  id: number
  cid: number
  content: string
  file_ids: string
  create_time: number
  admin_id: number
  admin_name?: string
  customer_name?: string
  follow_time?: number
  next_time?: number
  update_time?: number
  opportunity_id?: number // 关联的机会线索ID
  opportunity_title?: string // 机会线索标题
}

// 销售机会接口
export interface CustomerChance {
  id: number
  cid: number
  title: string
  stage: number
  discovery_time: number
  expected_time: number
  expected_order_amount: number
  content: string
  admin_id: number
  admin_name?: string
  create_time: number
  update_time: number
}

// 销售阶段选项接口
export interface StageOption {
  id: number
  title: string
}

// 客户日志接口
export interface CustomerLog {
  id: number
  field: string
  action: string
  type: number
  customer_id: number
  admin_id: number
  old_content: string
  new_content: string
  create_time: number
  admin_name?: string
}

// 导入统一的API响应类型
export type { ApiResponse } from './api'

// 客户状态接口
export interface CustomerState {
  customers: Customer[]
  customerTotal: number
  contacts: CustomerContact[]
  contactTotal: number
  traces: CustomerTrace[]
  traceTotal: number
  chances: CustomerChance[]
  chanceTotal: number
  logs: CustomerLog[]
  logTotal: number
}

// 客户列表参数接口
export interface CustomerListParams {
  page: number
  limit: number
  keywords?: string
  keyword?: string
  admin_id?: number | string
  user_id?: number | string
  is_lock?: number | string
  type?: string
  start_time?: string
  end_time?: string
  grade?: string
  grade_id?: string | number
  region?: string
  customer_status?: string | number
  department_id?: string | number
  level?: string | number
  important_level?: string | number
  status?: string | number
  is_cooperation?: string | number
  industry?: string
  scale?: string
  source?: string
  source_id?: string | number
  followup_filter?: string
  tags?: string[]
  business_type?: string
  create_time_start?: number
  create_time_end?: number
  cooperation_time_start?: number
  cooperation_time_end?: number
  member_status?: string | number
}
